package com.regent.central.bill.service.bean;

import com.regent.central.bill.common.ActionType;
import com.regent.central.bill.core.ModifyGoods;
import com.regent.central.bill.repository.ModifyGoodsMapper;
import com.regent.central.bill.service.ModifyGoodsService;
import com.regent.central.infrastructure.service.bean.DomainServiceBean;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ModifyGoodsServiceBean extends DomainServiceBean<ModifyGoodsMapper, ModifyGoods> implements ModifyGoodsService {
    /**
     * 删除改单货品
     *
     * @param modifyGoodsId 改单货品ID
     * @param userDeleted   删除人
     */
    @Override
    public void delete(String modifyGoodsId, String userDeleted) {
        mapper.hide(modifyGoodsId, userDeleted, System.currentTimeMillis());
    }

    /**
     * 根据改单动作ID删除改单货品
     *
     * @param modifyActionId 改单动作ID
     * @param userDeleted    删除人
     */
    @Override
    public void deleteForSaleOrderModifyAction(String modifyActionId, String userDeleted) {
        mapper.deleteForSaleOrderModifyAction(modifyActionId, userDeleted, System.currentTimeMillis());
    }

    /**
     * /**
     * 获取销售单的改欠货/被改欠货货品
     *
     * @param saleOrderId 销售单ID
     * @param actionType
     * @return 销售单的改欠货/被改欠货货品
     */
    @Override
    public List<ModifyGoods> getSaleOrderModifyGoods(String saleOrderId, ActionType actionType) {
        return getSaleOrderModifyGoods(saleOrderId, actionType, false, false);
    }

    /**
     * /**
     * 获取销售单的改欠货/被改欠货货品
     *
     * @param saleOrderId 销售单ID
     * @param actionType
     * @param canceled    已撤销
     * @param deleted     已删除   @return 销售单的改欠货/被改欠货货品
     */
    @Override
    public List<ModifyGoods> getSaleOrderModifyGoods(String saleOrderId, ActionType actionType, Boolean canceled, Boolean deleted) {
        return mapper.getSaleOrderModifyGoods(saleOrderId, actionType, canceled, deleted);
    }

    /**
     * 获取销售单父动作的改欠货/被改欠货货品列表
     *
     * @param parentActionId 父动作ID
     * @return 销售单父动作的改欠货/被改欠货货品列表
     */
    @Override
    public List<ModifyGoods> getSaleOrderModifyGoodsOfParent(String parentActionId) {
        return getSaleOrderModifyGoodsOfParent(parentActionId, false, false);
    }

    /**
     * 获取销售单父动作的改欠货/被改欠货货品列表
     *
     * @param parentActionId 父动作ID
     * @param canceled       已撤销
     * @param deleted        已删除
     * @return 销售单父动作的改欠货/被改欠货货品列表
     */
    @Override
    public List<ModifyGoods> getSaleOrderModifyGoodsOfParent(String parentActionId, Boolean canceled, Boolean deleted) {
        return mapper.getSaleOrderModifyGoodsOfParent(parentActionId, canceled, deleted);
    }
}